package com.itheima.examination2;

import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class SpringFestivalCountdown {
    public static void main(String[] args) {
        // 定义2026年春节时间
        LocalDateTime springFestival2026 = LocalDateTime.of(2026, 1, 22, 0, 0, 0);

        // 获取当前时间
        LocalDateTime now = LocalDateTime.now();

        // 计算时间差
        Duration duration = Duration.between(now, springFestival2026);

        // 提取天、小时、分钟、秒
        long totalSeconds = Math.max(0, duration.getSeconds());
        long days = totalSeconds / (24 * 60 * 60);
        long hours = (totalSeconds % (24 * 60 * 60)) / (60 * 60);
        long minutes = (totalSeconds % (60 * 60)) / 60;
        long seconds = totalSeconds % 60;

        // 格式化输出春节时间
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");

        System.out.println("2026年春节时间: " + springFestival2026.format(formatter));
        System.out.println("当前时间: " + now.format(formatter));
        System.out.println("距离2026年春节还有:");
        System.out.println("  " + days + " 天");
        System.out.println("  " + hours + " 小时");
        System.out.println("  " + minutes + " 分钟");
        System.out.println("  " + seconds + " 秒");
    }
}
